package com.qf.controller;

import com.qf.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/*
 *@Description:
 *@author:刘哥
 *@Date:19:43 2022/7/13
 */
//@RequestMapping包含@PostMapping(post请求)和@GetMapping(get请求)
//@Controller
//@ResponseBody
@RequestMapping("/user")
@RestController//==@Controller+@ResponseBody(将返回给前端的对象转为json格式)
public class UserController {
    @PostMapping("/tp")
    public String testPost(User user){
        System.out.println("user = " + user);
        return "success";
    }
//    get请求不带参数
    @GetMapping("tg")
    public User testGet(){
        User user=new User();
        user.setUsername(null);
        user.setPassword("888");
        user.setNikename("admin");
        user.setBirthday(new Date());
        return user;
    }
}
